package com.quickpass.order.controller;

import com.quickpass.order.domain.OrderDTO;
import com.quickpass.order.domain.ShopCart;
import com.quickpass.order.service.OrderService;
import com.quickpass.order.service.ShopCartService;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:
 * @author: 弔人
 * @time: 2023/2/6 9:49
 */
@RestController
@RequestMapping("/shopCart")
public class ShopCartController {
    @Autowired
    private ShopCartService shopCartService;

    @Autowired
    private OrderService orderService;


    /**
     * @description: 加入购物车
     * @return:
     * @author: 弔人
     * @time: 2023/2/6 10:22
     */
    @PostMapping("/addShopCart")
    public AjaxResult add(ShopCart shopCart){

        return shopCartService.addShopCart(shopCart);
    }


    /**
     * @description:
     * @return:
     * @author: 弔人
     * @time: 2023/2/6 10:22
     */
    @GetMapping("/getShopCartList/{userId}")
    public List<ShopCart> getSrtList(@PathVariable Long userId){
        return shopCartService.getShopCartList(userId);
    }

    @PostMapping("/createOrder")
    public AjaxResult creer(OrderDTO orderDTO){
        return orderService.createOrder(orderDTO);
    }
}
